<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .header {
            font-size: 2em;
            font-weight: bold;
            text-align: center;
        }
        .content {
            position: relative;
            width: 640px;
            margin: 0 auto;
            margin-top: 20px;
        }

        .content button {
            position: absolute;
            top: 2px;
            left: 2px;
            background-color: rgba(150, 150, 150, 0.6);
            border: 1px solid #999;
            text-shadow: 1px 1px 1px white;
            /* z-index: 1; */
            cursor: pointer;
        }

        .bigpic {
            width: 640px;
            height: 480px;
            background-color: rebeccapurple;
        }

        .smallpic {
            font-size: 0;
        }

        .smallpic img {
            width: 128px;
        }

        .mask {
            width: 640px;
            height: 480px;
            position: absolute;
            left: 0;
            top: 0;
        }

        .dark {
            background-color: rgba(0, 0, 0, 0.5);
        }

    </style>
</head>
<body>

    <div class="header">Image gallery example</div>

    <div class="content">
        
        <div class="bigpic">
            <img src="images/pic1.jpg" alt="img01">
        </div>
        <div class="smallpic">
            <img src="images/pic1.jpg" alt="">
            <img src="images/pic2.jpg" alt="">
            <img src="images/pic3.jpg" alt="">
            <img src="images/pic4.jpg" alt="">
            <img src="images/pic5.jpg" alt="">
        </div>
        <div class="mask"></div>
        <button>Lighten</button>
    </div>


<script>
    let bigpic = document.querySelector(".bigpic img")
    
    let smallpic = document.querySelector(".smallpic")

    smallpic.addEventListener("click", function(e) {
        bigpic.src = e.target.src
    })

    let btn = document.querySelector("button")
    let mask = document.querySelector(".mask")
    btn.addEventListener("click", function() {
        mask.classList.toggle("dark")
        if (btn.textContent == "Lighten") btn.textContent = "Darken"
        else btn.textContent = "Lighten"
    })
</script>
    
</body>
</html>